#include "PrecompiledHeader.h"
#include "DirectionalLight.h"

/*--------------------------------------------------------------------------*/

DirectionalLight::DirectionalLight(const NodeCreation& nc) :
	ILightSourceObject(nc)
{
	AssertModule(g_Material);

	/*--------------------------------------------------------------------------*/

	RenderTaskDesc desc;
	desc.m_material = g_Material->GetMaterial("mat_directionallight");
	desc.m_argument = 0;
	desc.m_flags = ERenderTaskFlag::LightSource | ERenderTaskFlag::Transparent;
	desc.m_priority = 0;
	desc.m_object = this;

	this->AddRenderTask(desc);

	/*--------------------------------------------------------------------------*/

	this->SetFrustumTestEnabled(false);
	this->SetRadius(FLT_MAX);
	this->SetPosition(glm::vec3());
}

/*--------------------------------------------------------------------------*/

DirectionalLight::~DirectionalLight()
{

}

/*--------------------------------------------------------------------------*/

void DirectionalLight::DrawLightVolume()
{
#ifdef VL_RENDER_STATISTICS
	g_Hud->GetStatisticsManager()->IncrementStatistic("DirectionalLight");
#endif
	ROpenGL::DrawFullscreenQuad();
}

/*--------------------------------------------------------------------------*/

const glm::vec3& DirectionalLight::GetDirection() const
{
	return this->m_direction;
}

/*--------------------------------------------------------------------------*/

void DirectionalLight::SetDirection(const glm::vec3& dir)
{
	this->m_direction = glm::normalize(dir);
}

/*--------------------------------------------------------------------------*/

void DirectionalLight::OnPreRender(const uint i, ERenderQuality::Type quality)
{
	//g_Material->SetLightningUBO(&this->GetRelativePosition(), &this->GetAmbient(), &this->GetSpecular(), &this->GetDiffuse(), NULL, NULL, &this->m_direction);
}

/*--------------------------------------------------------------------------*/
